# Contributor: Carlo Landmeter <clandmeter@alpinelinux.org>
# Maintainer: wener <wenermail@gmail.com>
pkgname=coturn
pkgver=4.6.2
pkgrel=0
pkgdesc="Free open source implementation of TURN and STUN Server"
url="https://github.com/coturn/coturn"
arch="all"
license="BSD-3-Clause"
makedepends="openssl-dev>3 libevent-dev linux-headers sqlite-dev libpq-dev hiredis-dev mariadb-dev"
pkgusers="$pkgname"
pkggroups="$pkgname"
install="$pkgname.pre-install"
subpackages="$pkgname-openrc $pkgname-static $pkgname-dev $pkgname-doc"
source="coturn-$pkgver.tar.gz::https://github.com/coturn/coturn/archive/$pkgver.tar.gz
	turnserver.initd
	"

# secfixes:
#   4.5.2-r0:
#     - CVE-2020-26262
#   4.5.1.3-r0:
#     - CVE-2020-4067

build() {
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share \
		--localstatedir=/var \
		--disable-rpath \
		--sysconfdir=/etc/$pkgname \
		--turndbdir=/var/lib/$pkgname
	make
}

check() {
	make test
}

package() {
	make DESTDIR="$pkgdir" install
	install -Dm755 "$srcdir"/turnserver.initd \
		"$pkgdir"/etc/init.d/turnserver
}

sha512sums="
ab8457921952a00b34111c03f2e5a2a9035977566270fdf9c8b9b777346645a8b233574134c0ef1c3aa2cf84bd89fbc82648678144c68ac0dff1712ce503b731  coturn-4.6.2.tar.gz
e686dc752618b2da2f6127ab11c49767bfcf228edf458cefe2853093baa845adb2b3159e850db1721e7474c4938fb237dd12bdfd7fd4db2ee73fbd0cb19af17d  turnserver.initd
"
